package com.example.zhengchaojun.arcgis;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ListView;

import com.example.zhengchaojun.arcgis.adapter.TrackAdapter;
import com.example.zhengchaojun.arcgis.basicesTest.BasicesActivity;
import com.example.zhengchaojun.arcgis.basicesTest.FeaturyAddDeleteActivity;
import com.example.zhengchaojun.arcgis.basicesTest.FeaturyEditActivity;
import com.example.zhengchaojun.arcgis.basicesTest.LayerManagerActivity;
import com.example.zhengchaojun.arcgis.basicesTest.MearueActivity;
import com.example.zhengchaojun.arcgis.basicesTest.QueryFeaturyActivity;
import com.example.zhengchaojun.arcgis.test.ArcgisSceneMapSolidActivity;
import com.example.zhengchaojun.arcgis.test.GaoDeActivity;
import com.example.zhengchaojun.arcgis.test.TestOtherMapActivity;
import com.example.zhengchaojun.arcgis.test.TianDiTuIMGMapActivityGG;
import com.example.zhengchaojun.arcgis.test.TianDiTuMapActivityGG;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * 类描述：
 * 作者：郑朝军 on 2018/5/10
 * 邮箱：1250393285@qq.com
 * 公司：武汉智博创享科技有限公司
 * 修改人：郑朝军 on 2018/5/10
 * 修改备注：
 */
public class ListActivity extends Activity
{
    private ListView m_listView;

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(getLayoutID());
        init();
    }

    public void init()
    {
        initView();
    }

    public int getLayoutID()
    {
        return R.layout.activity_list;
    }

    public void initView()
    {
        m_listView = findViewById(R.id.listView);
        setListViewData();
    }

    private void setListViewData()
    {
        String[] names = new String[]{"基础功能", "图层管理", "要素查询", "要素编辑添加，删除", "要素修改", "量距测算", "天地图矢量(二维)", "天地图影像(二维)", "三维地图天地图", "高德地图矢量（三维）", "高德地图影像（三维）", "百度地图矢量（三维）", "百度地图影像（三维）"};
        List<HashMap<String, Object>> list = new ArrayList<HashMap<String, Object>>();
        int length = names.length;
        for (int index = 0; index < length; index++)
        {
            HashMap<String, Object> map = new HashMap<String, Object>();
            map.put("text", names[index]);
            list.add(map);
        }
        TrackAdapter adapter = new TrackAdapter(this, list);
        m_listView.setAdapter(adapter);
    }

    public void onClick(View v)
    {
        switch (v.getId())
        {
            case R.id.list_item:
                doClickListItemView(v);
                break;
        }
    }

    private void doClickListItemView(View view)
    {
        int position = m_listView.getPositionForView(view);
        if (position == 0)
        {
            startActivity(BasicesActivity.class);
        }
        else if (position == 1)
        {
            startActivity(LayerManagerActivity.class);
        }
        else if (position == 2)
        {
            startActivity(QueryFeaturyActivity.class);
        }
        else if (position == 3)
        {
            startActivity(FeaturyAddDeleteActivity.class);
        }
        else if (position == 4)
        {
            startActivity(FeaturyEditActivity.class);
        }
        else if (position == 5)
        {
            startActivity(MearueActivity.class);
        }
        else if (position == 6)
        {// 天地图矢量(二维)
            startActivity(TianDiTuMapActivityGG.class);
        }
        else if (position == 7)
        {// 天地图影像(二维)
            startActivity(TianDiTuIMGMapActivityGG.class);
        }
        else if (position == 8)
        {// 三维地图天地图
            startActivity(ArcgisSceneMapSolidActivity.class);
        }
        else if (position == 9)
        {// 高德地图矢量（三维）
            startActivity(GaoDeActivity.class, 0);
        }
        else if (position == 10)
        {// 高德地图影像（三维）
            startActivity(GaoDeActivity.class, 1);
        }
        else if (position == 11)
        {// 百度地图矢量（三维）
            startActivity(TestOtherMapActivity.class);
        }
        else if (position == 12)
        {// 百度地图影像（三维）
            startActivity(GaoDeActivity.class, 3);
        }
    }

    public void startActivity(Class clazz)
    {
        Intent intent = new Intent(this, clazz);
        super.startActivity(intent);
    }

    public void startActivity(Class clazz, Serializable serializable)
    {
        Intent intent = new Intent(this, clazz);
        Bundle bundle = new Bundle();
        bundle.putSerializable("data", serializable);
        intent.putExtras(bundle);
        super.startActivity(intent);
    }
}
